
import packageConfig from '../../package.json'

// 版本号 -- token 的 key 值 根据版本号变化
export const version = packageConfig.version ? `v${packageConfig.version}` : 'v1.0.0'

export const tokenName = `token_${version}`

export const getToken = () => {
  return localStorage.getItem(tokenName)
}

export const setToken = (token) => localStorage.setItem(tokenName, token)

export const $formatSearchParam = (param = {}) => {
  let item = {}
  Object.keys(param).forEach(r => {
    if (Array.isArray(r) && r.length !== 0) {
      item[r] = param[r]
    }
    if(param[r] !== undefined){
      item[r] = param[r]
    }
  })
  return item
}